package org.tea.crawl.biz.controller;

import org.springframework.web.bind.annotation.*;
import org.tea.crawl.biz.common.ResponseResult;
import org.tea.crawl.biz.domain.dto.DomDataDto;
import org.tea.crawl.biz.domain.service.CrawlItemUrlService;

import javax.annotation.Resource;

/**
 * dom 服务的相关控制层
 *
 * @author lxh
 */
@RestController
@RequestMapping(path = "/dom")
public class DomServerController {

    @Resource
    private CrawlItemUrlService crawlItemUrlService;

    @PostMapping(path = "/nextItem")
    @CrossOrigin(origins = "*")
    public ResponseResult<?> nextItem() {
        return ResponseResult.success(crawlItemUrlService.findNextItemUrl());
    }

    @PostMapping(path = "/saveExecutedDom")
    @CrossOrigin(origins = "*")
    public ResponseResult<?> saveExecutedDom(@RequestBody DomDataDto dataDto) {
        crawlItemUrlService.saveDomContent(dataDto);
        return ResponseResult.success("success");
    }
}
